***********************************************************************************
* Are Major Customers Friends or Masters? Evidence from Customer Fraud Revelations*
* Authors: Shantanu Banerjee, Sudipto Dasgupta, Rui Shi							  *
***********************************************************************************
	
	* Basic configuration
	global pseudo "file path/..."
	global .... "file path/..."
	
	*Note: the pseudo data is created for the main regression results (Table 3 R&D)
	
	
	
	*Table 1: Firm chracteristics before the revelation of customers' fraud
	use "$.../main_sample.dta", clear
	
	tabstat rd, stat(n mean sd p25 med p75)
	tabstat numpat, stat(n mean sd p25 med p75)
	tabstat numpat_exploi, stat(n mean sd p25 med p75)
	tabstat numpat_explore, stat(n mean sd p25 med p75)
	tabstat ratio_exploi, stat(n mean sd p25 med p75)
	tabstat ratio_explore, stat(n mean sd p25 med p75)
	tabstat rd_risky, stat(n mean sd p25 med p75)
	tabstat tech_hhi, stat(n mean sd p25 med p75)
	tabstat tech_overlap, stat(n mean sd p25 med p75)
	tabstat age, stat(n mean sd p25 med p75)
	tabstat size, stat(n mean sd p25 med p75)
	tabstat tq, stat(n mean sd p25 med p75)
	tabstat leverage, stat(n mean sd p25 med p75)
	tabstat roa, stat(n mean sd p25 med p75)
	tabstat capex, stat(n mean sd p25 med p75)
	tabstat tangibility, stat(n mean sd p25 med p75)
	tabstat hindex, stat(n mean sd p25 med p75)
	
	
	
	
	
	
	
	
	
	****************************************************************************
	*Table 2: Summary statistics for the matched sample
	use "$.../matched_sample.dta", clear
	drop if post==1
	
	tabstat rd, stat(n mean) by(treated)
	tabstat numpat, stat(n mean) by(treated)
	tabstat numpat_exploi, stat(n mean) by(treated)
	tabstat numpat_explore, stat(n mean) by(treated)
	tabstat ratio_exploi, stat(n mean) by(treated)
	tabstat ratio_explore, stat(n mean) by(treated)
	tabstat rd_risky, stat(n mean) by(treated)
	tabstat tech_hhi, stat(n mean) by(treated)
	tabstat tech_overlap, stat(n mean) by(treated)
	tabstat age, stat(n mean) by(treated)
	tabstat size, stat(n mean) by(treated)
	tabstat tq, stat(n mean) by(treated)
	tabstat leverage, stat(n mean) by(treated)
	tabstat roa, stat(n mean) by(treated)
	tabstat capex, stat(n mean) by(treated)
	tabstat tangibility, stat(n mean) by(treated)
	tabstat hindex, stat(n mean) by(treated)
	
	
	reg rd treated, cluster(industry_code)
	reg numpat treated, cluster(industry_code)
	reg numpat_exploi treated, cluster(industry_code)
	reg numpat_explore treated, cluster(industry_code)
	reg ratio_exploi treated, cluster(industry_code)
	reg ratio_explore treated, cluster(industry_code)
	reg rd_risky treated, cluster(industry_code)
	reg tech_hhi treated, cluster(industry_code)
	reg tech_overlap treated, cluster(industry_code)
	reg age treated, cluster(industry_code)
	reg size treated, cluster(industry_code)
	reg tq treated, cluster(industry_code)
	reg leverage treated, cluster(industry_code)
	reg roa treated, cluster(industry_code)
	reg capex treated, cluster(industry_code)
	reg tangibility treated, cluster(industry_code)
	reg hindex treated, cluster(industry_code)
	
	




	****************************************************************************
	*Table 3: Stacked DID Results for Supplier R&D and Innovation Style
	use "$pseudo/pseudo_data.dta", clear
	tab time post
	drop if time == 0 /*revelation year*/
	gen treated_post = treated * post
	egen tc = group(cohort_id year)/*corhort post interactions*/
	egen ic = group(cohort_id firm_id)

	*column (1)
	reghdfe rd treated_post, abs(tc ic) cluster(industry_code)
	*column (2)
	ppmlhdfe numpat treated_post, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe rd_risky treated_post, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe numpat_exploi treated_post, abs(tc ic) cluster(industry_code)
	*column (5)
	ppmlhdfe numpat_explore treated_post, abs(tc ic) cluster(industry_code)
	*column (6)
	reghdfe tech_hhi treated_post, abs(tc ic) cluster(industry_code)
	*column (7)
	reghdfe tech_overlap treated_post, abs(tc ic) cluster(industry_code)
	
	
	
	
	
	
	
	
	****************************************************************************
	*Table 4: Managerial Myopia and Supplier Innovation
	clear
	use "$.../myopia_sample.dta", clear
	
	tab time post
	drop if time == 0 /*revelation year*/
	gen treated_post = treated * post
	
	*CEO Age Dummy: takes the value of one if a firm's CEO is above the median age of CEOs in the revelation year, and zero otherwise.
	gen tp_agedummy = treated_post * agedummy
	gen post_agedummy = post * agedummy
	
	*General ability index dummy: takes the value of one if the general ability index is above the median in the revelation year, and zero otherwise
	gen tp_gaidummy = treated_post * gaidummy
	gen post_gaidummy = post * gaidummy	
	
	*investor turnover dummy: takes the value of one if investor turnover is above the 75th percentile in the revelation year, and zero otherwise
	gen tp_todummy = treated_post * todummy
	gen post_todummy = post * todummy	
	
	egen tc = group(cohort_id year)/*corhort post interactions*/
	egen ic = group(cohort_id firm_id)

	*Panel A:
	*column (1)
	reghdfe rd treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	*column (2)
	ppmlhdfe numpat treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe rd_risky treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe numpat_exploi treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	*column (5)
	ppmlhdfe numpat_explore treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	*column (6)
	reghdfe tech_hhi treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	*column (7)
	reghdfe tech_overlap treated_post tp_agedummy post_agedummy if age<60, abs(tc ic) cluster(industry_code)
	
	
	*Panel B:
	*column (1)
	reghdfe rd treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	*column (2)
	ppmlhdfe numpat treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe rd_risky treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe numpat_exploi treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	*column (5)
	ppmlhdfe numpat_explore treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	*column (6)
	reghdfe tech_hhi treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	*column (7)
	reghdfe tech_overlap treated_post tp_gaidummy post_gaidummy, abs(tc ic) cluster(industry_code)
	
	
	*Panel C:
	*column (1)
	reghdfe rd treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
	*column (2)
	ppmlhdfe numpat treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe rd_risky treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe numpat_exploi treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
	*column (5)
	ppmlhdfe numpat_explore treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
	*column (6)
	reghdfe tech_hhi treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
	*column (7)
	reghdfe tech_overlap treated_post tp_todummy post_todummy, abs(tc ic) cluster(industry_code)
		
	
	
	
	
	
	
	
	****************************************************************************
	*Table 5: The effect of financial constraints
	clear
	use "$.../fc_sample.dta", clear
	
	tab time post
	drop if time == 0 /*revelation year*/
	gen treated_post = treated * post
	
	*Financial Constraint Dummy: "FC" indicates whether a supplier is financially constrained and takes the value of one for firms that are in the bottom third sorted by their size in the revelation year.
	gen tp_fcdummy = treated_post * fcdummy
	gen post_fcdummy = post * fcdummy
	
	
	egen tc = group(cohort_id year)/*corhort post interactions*/
	egen ic = group(cohort_id firm_id)

	
	*column (1)
	reghdfe rd treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	*column (2)
	ppmlhdfe numpat treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe rd_risky treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe numpat_exploi treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	*column (5)
	ppmlhdfe numpat_explore treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	*column (6)
	reghdfe tech_hhi treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	*column (7)
	reghdfe tech_overlap treated_post tp_fcdummy post_fcdummy, abs(tc ic) cluster(industry_code)
	
	
	
	
	
	
	****************************************************************************
	*Table 6: "Fraud years"
	clear
	use "$.../robustness_sample.dta", clear
	
	drop if year(evtdate) - year(fraud_lyear) >= 3
	tab time post
	drop if time == 0 /*revelation year*/
	
	gen treated_post = treated * post
	gen treated_during_fraud = trated * during_fraud
	gen treated_after_fraud = treated * after_fraud
	
	
	egen tc = group(cohort_id year)/*corhort post interactions*/
	egen ic = group(cohort_id firm_id)

	
	*column (1)
	reghdfe rd treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	*column (2)
	ppmlhdfe numpat treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe rd_risky treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe numpat_exploi treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	*column (5)
	ppmlhdfe numpat_explore treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	*column (6)
	reghdfe tech_hhi treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	*column (7)
	reghdfe tech_overlap treated_during_fraud treated_after_fraud treated_post, abs(tc ic) cluster(industry_code)
	
	
	
	
	
	
	
	
	****************************************************************************
	*Table 7: Supplier sales growth and customer base
	use "$.../sg.dta", clear
	
	tab time post
	drop if time == 0 /*revelation year*/
	gen treated_post = treated*post
	
	gen b4 = (time == -4)
	gen b3 = (time == -3)
	gen b2 = (time == -2)
	gen b1 = (time == -1)
	gen a1 = (time == 1)
	gen a2 = (time == 2)
	gen a3 = (time == 3)
	gen a4 = (time == 4)
	gen a5 = (time == 5)
	
	gen treated_b4 = treated * b4
	gen treated_b3 = treated * b3
	gen treated_b2 = treated * b2
	gen treated_b1 = treated * b1
	gen treated_a1 = treated * a1
	gen treated_a2 = treated * a2
	gen treated_a3 = treated * a3
	gen treated_a4 = treated * a4
	gen treated_a5 = treated * a5
	
	egen tc = group(cohort_id year)/*corhort post interactions*/
	egen ic = group(cohort_id firm_id)

	*column (1)
	reghdfe sg treated_post, abs(tc ic) cluster(industry_code)
	*column (2)
	reghdfe sg treated_b4 treated_b3 treated_b2 treated_b1 treated_a1 treated_a2 treated_a3 treated_a4 treated_a5, abs(tc ic) cluster(industry_code)
	*column (3)
	ppmlhdfe num_pc treated_post, abs(tc ic) cluster(industry_code)
	*column (4)
	ppmlhdfe num_pc treated_b4 treated_b3 treated_b2 treated_b1 treated_a1 treated_a2 treated_a3 treated_a4 treated_a5, abs(tc ic) cluster(industry_code)	
	
	
	
	
	
	
	
	
	****************************************************************************
	*Table 8: Tobin's Q and firm risk
	use "$.../tobinq_risk.dta", clear
	
	tab time post
	drop if time == 0 /*revelation year*/
	gen treated_post = treated*post
	
	gen b4 = (time == -4)
	gen b3 = (time == -3)
	gen b2 = (time == -2)
	gen b1 = (time == -1)
	gen a1 = (time == 1)
	gen a2 = (time == 2)
	gen a3 = (time == 3)
	gen a4 = (time == 4)
	gen a5 = (time == 5)
	
	gen treated_b4 = treated * b4
	gen treated_b3 = treated * b3
	gen treated_b2 = treated * b2
	gen treated_b1 = treated * b1
	gen treated_a1 = treated * a1
	gen treated_a2 = treated * a2
	gen treated_a3 = treated * a3
	gen treated_a4 = treated * a4
	gen treated_a5 = treated * a5
	
	egen tc = group(cohort_id year)/*corhort post interactions*/
	egen ic = group(cohort_id firm_id)

	*column (1)
	reghdfe tq treated_post, abs(tc ic) cluster(industry_code)
	*column (2)
	reghdfe tq treated_b4 treated_b3 treated_b2 treated_b1 treated_a1 treated_a2 treated_a3 treated_a4 treated_a5, abs(tc ic) cluster(industry_code)
	*column (3)
	reghdfe risk treated_post, abs(tc ic) cluster(industry_code)
	*column (4)
	reghdfe risk treated_b4 treated_b3 treated_b2 treated_b1 treated_a1 treated_a2 treated_a3 treated_a4 treated_a5, abs(tc ic) cluster(industry_code)	
	

	
	
	
	
	****************************************************************************
	*Table 9: Linear probability and probit models of survival
	clear
	use "$.../survival_1.dta", clear
	
	gen time = year - year(evtdate) 
	tab time
	drop if time <= 0 /*revelation year and pre-revelation years*/
	
	
	*column (1)
	reghdfe failure treated size tq leverage roa capex tangibility hindex hindex_2 if time<=3, abs(year industry_code) cluster(industry_code)
	*column (2)
	reghdfe failure treated size tq leverage roa capex tangibility hindex hindex_2 if time>3, abs(year industry_code) cluster(industry_code)
	*column (3)
	probit failure treated size tq leverage roa capex tangibility hindex hindex_2 i.year i.industry_code if time<=3, cluster(industry_code)
	*column (4)
	probit failure treated size tq leverage roa capex tangibility hindex hindex_2 i.year i.industry_code if time>3 , cluster(industry_code)	
	
	
	
	
	
	
	****************************************************************************
	*Table 10: Firm survival and explorative vs. exploitative innovation
	clear
	use "$.../survival_2.dta", clear
		
	*column (1)
	reghdfe failure cum_exploi_lnp treated size tq leverage roa capex tangibility hindex hindex_2, abs(year industry_code) cluster(industry_code)
	*column (2)
	reghdfe failure cum_explor_lnp treated size tq leverage roa capex tangibility hindex hindex_2, abs(year industry_code) cluster(industry_code)
	*column (3)
	probit failure cum_exploi_lnp treated size tq leverage roa capex tangibility hindex hindex_2 i.year i.industry_code, cluster(industry_code)
	*column (4)
	probit failure cum_explor_lnp treated size tq leverage roa capex tangibility hindex hindex_2 i.year i.industry_code, cluster(industry_code)	
	
	
	
	
	
	
	
	
	
	****************************************************************************
	*Table 11: Cross-sectional regressions: Survival over a ten-year horizon and
	*the effect of mediating variables
	clear
	use "$.../survival_3.dta", clear
	
	
	*Panel (A):
	
	*column (1)
	reghdfe failure treated size tq leverage roa capex tangibility hindex hindex_2, abs(industry_code) cluster(industry_code)
	*column (2)
	probit failure treated size tq leverage roa capex tangibility hindex hindex_2 i.industry_code, cluster(industry_code)
	*column (3)
	reghdfe ch_sales_pc treated size tq leverage roa capex tangibility hindex hindex_2, abs(industry_code) cluster(industry_code)	
	*column (4)
	reghdfe explore5 treated size tq leverage roa capex tangibility hindex hindex_2, abs(industry_code) cluster(industry_code)	
	*column (5)
	reghdfe sga5 treated size tq leverage roa capex tangibility hindex hindex_2, abs(industry_code) cluster(industry_code)
	*column (6)
	reghdfe rd5 treated size tq leverage roa capex tangibility hindex hindex_2, abs(industry_code) cluster(industry_code)
	
	
	
	*Panel (B):
	
	*column (1)
	ivmediate failure size tq leverage roa capex tangibility hindex hindex_2 i.industry_code, med(explore5) treat(ch_sales_pc) inst(treated)  vce(cluster industry_code)
	*column (2)
	ivmediate failure size tq leverage roa capex tangibility hindex hindex_2 i.industry_code, med(sga5) treat(ch_sales_pc) inst(treated)  vce(cluster industry_code)
	*column (3)
	ivmediate failure size tq leverage roa capex tangibility hindex hindex_2 i.industry_code, med(rd5) treat(ch_sales_pc) inst(treated)  vce(cluster industry_code)
	
	
	
	
	
	
	
	
	
	
	
